import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import '../color.dart';
import '../text_style.dart';

class UpdateDialog extends Dialog {
  final VoidCallback? yesCallback;
  final VoidCallback? noCallback;
  final String? tipsTitle;
  final VoidCallback? phoneCallback;
  final Widget? content;
  final String? phone;
  final String? yesStr;
  final String? end;
  final String? center;
  final String? noStr;
  final TextAlign? textAlign;
  bool? isShow=false;
  UpdateDialog({
    Key? key,
    this.yesCallback,
    this.noCallback,
    this.tipsTitle,
    this.phoneCallback,
    this.content,
    this.yesStr,
    this.noStr,
    this.phone,
    this.end,
    this.center,
    this.textAlign,
    this.isShow
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Material(
      color: Colors.transparent,
      child: Center(
        child: Container(
          margin: EdgeInsets.only(left: 32.w, right: 32.w),
          decoration: BoxDecoration(
            color: Colors.white,
            borderRadius: BorderRadius.circular(8.w),
          ),
          constraints: BoxConstraints(minHeight: 156.w),
          child: Column(
            mainAxisSize: MainAxisSize.min,
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              Container(
                margin: EdgeInsets.only(bottom: 24.w,top: 15.w),
                child: Text(
                  tipsTitle ?? '提示',
                  style: TextStyleUtils.style323233(
                      fontSize: 16.sp, fontWeight: FontWeight.w500),
                ),
              ),
              Container(
                alignment: Alignment.center,
                child:content,
              ),
              SizedBox(height: 24.w),
              Container(height: 0.5.w, color: ColorManager.colorE5E5E5),
              Container(
                margin: EdgeInsets.symmetric(horizontal: 24.w),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Visibility(
                      visible: isShow!,
                      child: Expanded(
                        child: InkWell(
                          onTap: noCallback ?? () => Navigator.pop(context),
                          child: Container(
                            height: 50.w,
                            decoration: BoxDecoration(
                              border: Border(
                                right: BorderSide(
                                    width: 0.5.w, color: ColorManager.colorE5E5E5),
                              ),
                            ),
                            alignment: Alignment.center,
                            child: Text(
                              noStr ?? '取消',
                              style: TextStyleUtils.style999999(
                                fontSize: 16.sp,
                              ),
                            ),
                          ),
                        ),
                      ),
                    ),
                    Expanded(
                      child: InkWell(
                        onTap: () => yesCallback!(),
                        child: Container(
                          height: 50.w,
                          alignment: Alignment.center,
                          child: Text(
                            yesStr ?? '确定',
                            style: TextStyleUtils.style5681F2(
                              fontSize: 16.sp,
                            ),
                          ),
                        ),
                      ),
                    ),
                  ],
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
